package handler

import (
	"Gin/api/request"
	"Gin/global/model"
	"Serve/VideoSrv"
	"context"
	"github.com/gin-gonic/gin"
	"net/http"
)

func VideoData(c *gin.Context) {
	var VideoDataRequest request.VideoDataRequest
	if err := c.ShouldBind(&VideoDataRequest); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code":    400,
			"message": err.Error(),
		})
		return
	}
	data, err := model.VideoClient.VideoData(context.Background(), &VideoSrv.VideoDataRequest{
		VideoId: int64(VideoDataRequest.VideoId),
	})
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code":    400,
			"message": err.Error(),
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "success",
		"data":    data,
	})
}
